 package CurtainDesign;

 import CurtainDesign.utils.CalculateUtils;
 import CurtainDesign.utils.CurtainChecker;
 import CurtainDesign.utils.HingeRelatedInfo;
 import CurtainDesign.utils.Translator;
 import NewOrderXmlbean.Comments;
 import NewOrderXmlbean.Leveldescinfo;
 import NewOrderXmlbean.Levelinfo;
 import NewOrderXmlbean.OrderDocument;
 import NewOrderXmlbean.OrderDocument.Factory;
 import NewOrderXmlbean.Orderinfo;
 import java.io.File;
 import java.text.DateFormat;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import javax.swing.JOptionPane;
 import org.apache.log4j.Logger;

 /**
  * 普通方形订单
  */
 public class OrderFileRectSimple extends OrderFile
 {
   private Logger logger = Logger.getLogger(OrderFileRectSimple.class);

   public boolean ReadOrderFile(String orderfile)
   {
     try
     {
       File xmlfile = new File(orderfile);
       OrderDocument doc = OrderDocument.Factory.parse(xmlfile);
       Orderinfo orderinfo = doc.getOrder();
       Translator.english2Chinese(orderinfo);

       String tmp = orderinfo.getWindowtype();
       if ((tmp == null) || (tmp.equals("")) || (!tmp.equals(Constants.STYLES[0]))) {
         JOptionPane.showMessageDialog(null, "窗户类型错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getOrderindex();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveOrderIndex(tmp);
       }
       else
       {
         JOptionPane.showMessageDialog(null, "读取订单编号错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getClientregion();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveClientRegion(tmp);
       } else {
         JOptionPane.showMessageDialog(null, "读取客户区域错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getOrderdate();
       if (!CurtainChecker.isEmpty(tmp)) {
         DateFormat dtformat = new SimpleDateFormat("ddMMyyyy");
         Date date = dtformat.parse(tmp);
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveOrderDate(date);

         long dlDate = date.getTime() + 691200000L;
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDeliverDate(new Date(dlDate));
       }
       else {
         JOptionPane.showMessageDialog(null, "读取下单日期错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getRoom();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveRoom(tmp);
       } else {
         JOptionPane.showMessageDialog(null, "读取房间号错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getPipeindex();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SavePipeIndex(tmp);
       }
       else
       {
         String pipeIndexStr = CurtainDesign.m_PipeIndexFile.GetPipeIndex(Constants.STYLES[0], true);
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SavePipeIndex(pipeIndexStr);
       }

       tmp = orderinfo.getCustomerrefnum();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().saveCustRefNum(tmp);
       }

       tmp = orderinfo.getWindownum();
       if (!CurtainChecker.isEmpty(tmp))
       {
         if (CurtainChecker.isInteger(tmp))
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveWindowNum(tmp);
         }
         else
         {
           JOptionPane.showMessageDialog(null, "窗户总必须为一个整数！", "读文件错误", 0);
           return false;
         }

       }
       else
       {
         JOptionPane.showMessageDialog(null, "读取窗户总数错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getWindowindex();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveWindowIndex(tmp);
       } else {
         JOptionPane.showMessageDialog(null, "读取窗户编号错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getWoodoption();
       if (!CurtainChecker.isEmpty(tmp))
       {
         int index = -1;
         for (int i = 0; i < Constants.WOODOPTION.length; i++)
         {
           if (!Constants.WOODOPTION[i].equals(tmp))
             continue;
           index = i;
           break;
         }

         if (index > -1)
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveWoodOption(index);
         }

       }
       else
       {
         JOptionPane.showMessageDialog(null, "读取木材选择错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getColor();
       if (!CurtainChecker.isEmpty(tmp))
       {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveColor(tmp);
       }
       else
       {
         JOptionPane.showMessageDialog(null, "读取颜色错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getOriwindowwidth();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveOriWindowWidth(tmp);
       }
       else {
         JOptionPane.showMessageDialog(null, "读取窗户宽度错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getOriwindowheight();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveOriWindowHeight(tmp);
       }
       else
       {
         JOptionPane.showMessageDialog(null, "读取窗户高度错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getInstall();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveInstall(tmp);
       } else {
         JOptionPane.showMessageDialog(null, "读取安装方式错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getHingecolor();
       if (!CurtainChecker.isEmpty(tmp))
       {
         int index = -1;
         for (int i = 0; i < Constants.HINGECOLOR.length; i++)
         {
           if (!Constants.HINGECOLOR[i].equals(tmp))
             continue;
           index = i;
           break;
         }

         if (index > -1)
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveHingeColor(index);
         }

       }
       else
       {
         JOptionPane.showMessageDialog(null, "读取合页颜色错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getFramenumpos();
       if (!CurtainChecker.isEmpty(tmp))
       {
         int index = -1;
         for (int i = 0; i < Constants.FRAMENUMPOS.length; i++)
         {
           if (!Constants.FRAMENUMPOS[i].equals(tmp))
             continue;
           index = i;
           break;
         }

         if (index > -1)
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveFrameNumPos(index);
         }
       }
       else
       {
         JOptionPane.showMessageDialog(null, "读取外框类型和数量错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getFrametype();
       if (!CurtainChecker.isEmpty(tmp))
       {
         int index = -1;
         for (int i = 0; i < Constants.FRAMETYPE.length; i++)
         {
           if (!Constants.FRAMETYPE[i].equals(tmp))
             continue;
           index = i;
           break;
         }

         if (index > -1)
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveFrameType(index);
         }

       }
       else if (!orderinfo.getFramenumpos().trim().equals(Constants.FRAMENUMPOS[2]))
       {
         JOptionPane.showMessageDialog(null, "读取外框类型错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = orderinfo.getPullbartype();
       if (!CurtainChecker.isEmpty(tmp)) {
         int index = -1;
         for (int i = 0; i < Constants.PULLBARTYPE.length; i++) {
           if (Constants.PULLBARTYPE[i].equals(tmp)) {
             index = i;
             break;
           }
         }
         if (index > -1)
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SavePullBarType(index);
       }
       else
       {
         JOptionPane.showMessageDialog(null, "读取拉杆类型错误，请检查", "读文件错误", 0);

         return false;
       }

       boolean tag = orderinfo.getRoundmagnet();
       CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveIsRoundMagnet(tag);

       tmp = orderinfo.getTpoletype();
       if (!CurtainChecker.isEmpty(tmp))
       {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().saveTPoleType(tmp);
       }
       else
       {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().saveTPoleType(Constants.T_POLE_TYPE[3]);
       }

       boolean isAutoAddDivider = orderinfo.getAutoadddivider();
       CurtainDesign.m_UserMainGUI.GetOrderInfo().saveAutoAddDivider(isAutoAddDivider);

       tmp = orderinfo.getLevelArray().length + "";
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveLevel(tmp);
       } else {
         JOptionPane.showMessageDialog(null, "读取层数错误，请检查", "读文件错误", 0);

         return false;
       }
       Leveldescinfo levelDesc = orderinfo.getLeveldesc();

       tag = levelDesc.getSamelevelheight();
       CurtainDesign.m_UserMainGUI.GetOrderInfo().saveSameHeight(tag);

       tag = levelDesc.getHorizontalt();
       CurtainDesign.m_UserMainGUI.GetOrderInfo().saveHTPoleExist(tag);

       tmp = levelDesc.getHorizontaltposition();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().saveHtPolePos(tmp);
       }
       else if ((!levelDesc.getSamelevelheight()) && (!levelDesc.getLevelnum().trim().equals("1")))
       {
         JOptionPane.showMessageDialog(null, "读取横T/分隔线高度错误，请检查", "读文件错误", 0);

         return false;
       }

       Levelinfo[] levelsinfo = orderinfo.getLevelArray();

       tag = levelsinfo[0].getSamepanelwidth();
       CurtainDesign.m_UserMainGUI.GetOrderInfo().saveSamePanelWidth(tag);

       tag = levelsinfo[0].getBoard();
       CurtainDesign.m_UserMainGUI.GetOrderInfo().saveIsBoard(tag);

       tmp = levelsinfo[0].getHingeinstalltype();
       if (!CurtainChecker.isEmpty(tmp))
       {
         tmp = CalculateUtils.formatHingeInstallType(tmp);

         if (CurtainChecker.isVaildHingeInstall(tmp, CurtainChecker.simpleRectRegex))
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveHingeInstallType(tmp);

           HingeRelatedInfo info = CalculateUtils.getSimpleRectHingeRelatedInfo(tmp);
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SavePanelNum(new Integer(info.getPaneNum()).toString());
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBendHinge(new Integer(info.getBendHingePaneNum()).toString());
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveSingleHinge(new Integer(info.getSingleHingePaneNum()).toString());
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDoubleHinge(new Integer(info.getDoubleHingePaneNum()).toString());
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SavePoleNum(new Integer(info.getPoleNum()).toString());
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDuiKouPoleNum(new Integer(info.getDuikouPoleNum()).toString());
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveShuangLianPoleNum(new Integer(info.getShuanglianPoleNum()).toString());
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveTPoleNum(new Integer(info.getTPoleNum()).toString());
           DecimalFormat nFormat = new DecimalFormat();
           nFormat.setMaximumFractionDigits(2);
           nFormat.setGroupingSize(10);
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveGap(nFormat.format(info.getGap()));
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveMagnetSliceNum(info.getMagnetSliceNum());
         }
         else
         {
           JOptionPane.showMessageDialog(null, "（上层）窗户的合页安装方式不合法，请检查！", "读文件错误", 0);
           return false;
         }

       }
       else
       {
         JOptionPane.showMessageDialog(null, "读取合页安装方式错误，请检查！", "读文件错误", 0);
         return false;
       }

       tmp = levelsinfo[0].getPanelnum();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SavePanelNum(tmp);
       }

       tmp = levelsinfo[0].getVerticaltposition();
       if (!CurtainChecker.isEmpty(tmp))
       {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveTPolePos(tmp);
       }
       else if (levelsinfo[0].getHingeinstalltype().split("T").length > 1)
       {
         if (!levelsinfo[0].getSamepanelwidth())
         {
           JOptionPane.showMessageDialog(null, "读取T型立杆位置错误，请检查", "读文件错误", 0);

           return false;
         }

       }

       tmp = levelsinfo[0].getBendhinge();
       if (!CurtainChecker.isEmpty(tmp))
       {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBendHinge(tmp);
       }

       tmp = levelsinfo[0].getSinglehinge();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveSingleHinge(tmp);
       }

       tmp = levelsinfo[0].getDoublehinge();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDoubleHinge(tmp);
       }

       tmp = levelsinfo[0].getPolenum();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SavePoleNum(tmp);
       }

       tmp = levelsinfo[0].getDuikoupolenum();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDuiKouPoleNum(tmp);
       }

       tmp = levelsinfo[0].getHingeinstalltype();
       if (tmp.split("T").length > 1)
       {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveTPoleNum(new Integer(tmp.split("T").length - 1).toString());
       }

       tmp = levelsinfo[0].getGap();
       if (!CurtainChecker.isEmpty(tmp))
       {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveGap(tmp);
       }

       tmp = levelsinfo[0].getShuanglianpolenum();
       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().saveShuangLianPoleNum(tmp);
       }

       tmp = levelsinfo[0].getVanetype();
       if (!CurtainChecker.isEmpty(tmp))
       {
         int index = -1;
         float vaneWidth = new Float(tmp).floatValue();
         for (int i = 0; i < Constants.VANETYPE.length; i++)
         {
           if (vaneWidth != new Float(Constants.VANETYPE[i]).floatValue())
             continue;
           index = i;
           break;
         }

         if (index > -1)
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveVaneType(index);
         }

       }
       else if (!levelsinfo[0].getBoard())
       {
         JOptionPane.showMessageDialog(null, "读取叶片规格错误，请检查", "读文件错误", 0);

         return false;
       }

       tmp = levelsinfo[0].getDividertype();
       if (!CurtainChecker.isEmpty(tmp)) {
         int index = -1;
         float fDividerWidth = new Float(tmp).floatValue();
         for (int i = 0; i < Constants.DIVIDERTYPE.length; i++)
         {
           if (new Float(Constants.DIVIDERTYPE[i]).floatValue() != fDividerWidth)
             continue;
           index = i;
           break;
         }

         if (index > -1)
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDividerType(index);
         }

       }
       else if ((!levelsinfo[0].getBoard()) && (!CurtainChecker.isEmpty(levelsinfo[0].getDividernum())))
       {
         int vanetype = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetVaneType();
         if ((vanetype == 0) || (vanetype == 2)) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDividerType(2);
         }
         else if (vanetype == 1) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDividerType(0);
         }
         else if (vanetype == 3)
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDividerType(1);
         }
         else
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDividerType(3);
         }

       }

       tmp = levelsinfo[0].getDividernum();

       if (!CurtainChecker.isEmpty(tmp)) {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDividerNum(tmp);
       }
       else
       {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDividerNum("0");
       }

       tmp = levelsinfo[0].getDividerpos();
       if (!CurtainChecker.isEmpty(tmp))
       {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveDividerPos(tmp);
       }
       else if ((!levelsinfo[0].getBoard()) && (!CurtainChecker.isEmpty(levelsinfo[0].getDividernum())) && (Integer.parseInt(levelsinfo[0].getDividernum()) > 0))
       {
         JOptionPane.showMessageDialog(null, "读取DividerPos错误，请检查", "读文件错误", 0);
         return false;
       }

       if ((levelsinfo.length == 2) && (levelDesc.getLevelnum().trim().equals("2")))
       {
         tag = levelsinfo[1].getSamepanelwidth();
         CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomSameWidth(tag);

         tag = levelsinfo[1].getBoard();
         CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomIsBoard(tag);

         tmp = levelsinfo[1].getHingeinstalltype();
         if (!CurtainChecker.isEmpty(tmp))
         {
           tmp = CalculateUtils.formatHingeInstallType(tmp);

           if (CurtainChecker.isVaildHingeInstall(tmp, CurtainChecker.simpleRectRegex))
           {
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomHingeInstallType(tmp);
             HingeRelatedInfo info = CalculateUtils.getSimpleRectHingeRelatedInfo(tmp);
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomPanelNum(new Integer(info.getPaneNum()).toString());
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomBendHinge(new Integer(info.getBendHingePaneNum()).toString());
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomSingeHinge(new Integer(info.getSingleHingePaneNum()).toString());
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDoubleHinge(new Integer(info.getDoubleHingePaneNum()).toString());
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomPoleNum(new Integer(info.getPoleNum()).toString());
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDuiKouPoleNum(new Integer(info.getDuikouPoleNum()).toString());
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomShuangLianPoleNum(new Integer(info.getShuanglianPoleNum()).toString());
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomTPoleNum(new Integer(info.getTPoleNum()).toString());
             DecimalFormat nFormat = new DecimalFormat();
             nFormat.setMaximumFractionDigits(2);
             nFormat.setGroupingSize(10);
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomGap(nFormat.format(info.getGap()));
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveMagnetSliceNum(CurtainDesign.m_UserMainGUI.GetOrderInfo().getMagnetSliceNum() + info.getMagnetSliceNum());
           }
           else
           {
             JOptionPane.showMessageDialog(null, "下层窗户的合页安装方式不合法，请检查！", "读文件错误", 0);
             return false;
           }
         }
         else
         {
           JOptionPane.showMessageDialog(null, "读取下层合页安装方式错误，请检查", "读文件错误", 0);

           return false;
         }

         tmp = levelsinfo[1].getPanelnum();
         if (!CurtainChecker.isEmpty(tmp)) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomPanelNum(tmp);
         }

         tmp = levelsinfo[1].getVerticaltposition();
         if (!CurtainChecker.isEmpty(tmp))
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomTPolePos(tmp);
         }
         else if (levelsinfo[1].getHingeinstalltype().split("T").length > 1)
         {
           tag = levelDesc.getHorizontalt();
           if (!levelsinfo[1].getSamepanelwidth())
           {
             if (levelDesc.getHorizontalt())
             {
               JOptionPane.showMessageDialog(null, "读取下层T型立杆位置错误，请检查", "读文件错误", 0);

               return false;
             }

           }

         }

         tmp = levelsinfo[1].getBendhinge();
         if (!CurtainChecker.isEmpty(tmp))
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomBendHinge(tmp);
         }

         tmp = levelsinfo[1].getSinglehinge();
         if (!CurtainChecker.isEmpty(tmp)) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomSingeHinge(tmp);
         }

         tmp = levelsinfo[1].getDoublehinge();
         if (!CurtainChecker.isEmpty(tmp)) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDoubleHinge(tmp);
         }

         tmp = levelsinfo[1].getPolenum();
         if (!CurtainChecker.isEmpty(tmp)) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomPoleNum(tmp);
         }

         tmp = levelsinfo[1].getDuikoupolenum();
         if (!CurtainChecker.isEmpty(tmp)) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDuiKouPoleNum(tmp);
         }

         tmp = levelsinfo[1].getHingeinstalltype();
         if (tmp.split("T").length > 1)
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomTPoleNum(new Integer(tmp.split("T").length - 1).toString());
         }

         tmp = levelsinfo[1].getGap();
         if (!CurtainChecker.isEmpty(tmp))
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomGap(tmp);
         }

         tmp = levelsinfo[1].getShuanglianpolenum();
         if (!CurtainChecker.isEmpty(tmp)) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomShuangLianPoleNum(tmp);
         }

         tmp = levelsinfo[1].getVanetype();
         if (!CurtainChecker.isEmpty(tmp)) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomVaneType(tmp);
         }
         else if (!levelsinfo[1].getBoard())
         {
           JOptionPane.showMessageDialog(null, "读取下层叶片规格错误，请检查", "读文件错误", 0);

           return false;
         }

         tmp = levelsinfo[1].getDividertype();
         if (!CurtainChecker.isEmpty(tmp))
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDividerType(tmp);
         }
         else if ((!levelsinfo[1].getBoard()) && (!CurtainChecker.isEmpty(levelsinfo[1].getDividernum())))
         {
           String vaneTypeStr = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomVaneType();
           if ((new Float(vaneTypeStr).floatValue() == new Float(Constants.VANETYPE[0]).floatValue()) || (new Float(vaneTypeStr).floatValue() == new Float(Constants.VANETYPE[2]).floatValue()))
           {
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDividerType(Constants.DIVIDERTYPE[2]);
           }
           else if (new Float(vaneTypeStr).floatValue() == new Float(Constants.VANETYPE[1]).floatValue()) {
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDividerType(Constants.DIVIDERTYPE[0]);
           }
           else if (new Float(vaneTypeStr).floatValue() == new Float(Constants.VANETYPE[3]).floatValue())
           {
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDividerType(Constants.DIVIDERTYPE[1]);
           }
           else
           {
             CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDividerType(Constants.DIVIDERTYPE[3]);
           }

         }

         tmp = levelsinfo[1].getDividernum();

         if (!CurtainChecker.isEmpty(tmp)) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDividerNum(tmp);
         }
         else
         {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDividerNum("0");
         }

         tmp = levelsinfo[1].getDividerpos();
         if (!CurtainChecker.isEmpty(tmp)) {
           CurtainDesign.m_UserMainGUI.GetOrderInfo().saveBottomDividerPos(tmp);
         }
         else if ((!CurtainChecker.isEmpty(levelsinfo[1].getDividernum())) && (Integer.parseInt(levelsinfo[1].getDividernum()) > 0))
         {
           JOptionPane.showMessageDialog(null, "读取下层分隔梁位置错误，请检查", "读文件错误", 0);

           return false;
         }

       }

       tmp = orderinfo.getMagnetslice();
       if (!CurtainChecker.isEmpty(tmp))
       {
         CurtainDesign.m_UserMainGUI.GetOrderInfo().saveMagnetSliceNum(Integer.parseInt(tmp));
       }

       Comments commentsObj = orderinfo.getComments();
       String[] comments = null;
       if (null != commentsObj)
       {
         comments = commentsObj.getCommentArray();
       }
       int arrLen = 0;
       if ((null != comments) && ((arrLen = comments.length) > 0))
       {
         StringBuffer buff = new StringBuffer();
         for (int i = 0; i < arrLen; i++)
         {
           buff.append(comments[i]);
           if (i >= arrLen - 1)
             continue;
           buff.append("@@");
         }

         CurtainDesign.m_UserMainGUI.GetOrderInfo().SaveComments(buff.toString());
       }
     }
     catch (Exception e)
     {
       e.printStackTrace();
       return false;
     }
     return true;
   }

   public void WriteOrderFile(String orderfile, boolean newopenedfile, boolean override)
   {
     try
     {
       File xmlfile = new File(orderfile);
       OrderDocument doc = OrderDocument.Factory.newInstance();
       Orderinfo orderinfo = doc.addNewOrder();

       orderinfo.setWindowtype(Constants.STYLES[0]);

       String tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetOrderIndex();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         orderinfo.setOrderindex(tmpstring);
       }

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetClientRegion();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         orderinfo.setClientregion(tmpstring);
       }

       Date tmpdate = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetOrderDate();
       DateFormat dtformat = new SimpleDateFormat("ddMMyyyy");
       orderinfo.setOrderdate(dtformat.format(tmpdate));

       long dlDate = tmpdate.getTime() + 691200000L;
       tmpdate = new Date(dlDate);
       orderinfo.setDeliverdate(dtformat.format(tmpdate));

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetRoom();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         orderinfo.setRoom(tmpstring);
       }

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetPipeIndex();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         orderinfo.setPipeindex(tmpstring);
       }

       orderinfo.setCustomerrefnum(CurtainDesign.m_UserMainGUI.GetOrderInfo().getCustRefNum());

       orderinfo.setWindownum(CurtainDesign.m_UserMainGUI.GetOrderInfo().GetWindowNum());

       orderinfo.setWindowindex(CurtainDesign.m_UserMainGUI.GetOrderInfo().GetWindowIndex());

       int tmpint = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetWoodOption();
       if (tmpint > -1)
         orderinfo.setWoodoption(Constants.WOODOPTION[tmpint]);
       else {
         orderinfo.setWoodoption("");
       }

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetColor();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         orderinfo.setColor(tmpstring);
       }

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetOriWindowWidth();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         orderinfo.setOriwindowwidth(tmpstring);
       }

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetOriWindowHeight();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         orderinfo.setOriwindowheight(tmpstring);
       }

       orderinfo.setInstall(CurtainDesign.m_UserMainGUI.GetOrderInfo().GetInstall());

       tmpint = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetHingeColor();
       if (tmpint > -1)
         orderinfo.setHingecolor(Constants.HINGECOLOR[tmpint]);
       else {
         orderinfo.setHingecolor("");
       }

       tmpint = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetFrameNumPos();
       if (tmpint > -1)
         orderinfo.setFramenumpos(Constants.FRAMENUMPOS[tmpint]);
       else {
         orderinfo.setFramenumpos("");
       }

       tmpint = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetFrameType();
       if (tmpint > -1)
         orderinfo.setFrametype(Constants.FRAMETYPE[tmpint]);
       else {
         orderinfo.setFrametype("");
       }

       tmpint = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetPullBarType();
       if (tmpint > -1)
         orderinfo.setPullbartype(Constants.PULLBARTYPE[tmpint]);
       else {
         orderinfo.setPullbartype("");
       }

       orderinfo.setRoundmagnet(CurtainDesign.m_UserMainGUI.GetOrderInfo().IsRoundMagnet());

       tmpint = CurtainDesign.m_UserMainGUI.GetOrderInfo().getMagnetSliceNum();
       if (tmpint > 0)
       {
         orderinfo.setMagnetslice(Integer.toString(tmpint));
       }

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getTPoleType();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         orderinfo.setTpoletype(CurtainDesign.m_UserMainGUI.GetOrderInfo().getTPoleType());
       }

       orderinfo.setAutoadddivider(CurtainDesign.m_UserMainGUI.GetOrderInfo().getAutoAddDivider());

       Leveldescinfo levelDesc = orderinfo.addNewLeveldesc();
       levelDesc.setLevelnum(CurtainDesign.m_UserMainGUI.GetOrderInfo().GetLevel());
       if (CurtainDesign.m_UserMainGUI.GetOrderInfo().GetLevel().trim().equals("2"))
       {
         levelDesc.setSamelevelheight(CurtainDesign.m_UserMainGUI.GetOrderInfo().getSameHeight());

         levelDesc.setHorizontalt(CurtainDesign.m_UserMainGUI.GetOrderInfo().getHTPoleExist());

         levelDesc.setHorizontaltposition(CurtainDesign.m_UserMainGUI.GetOrderInfo().getHtPolePos());
       }
       orderinfo.setLeveldesc(levelDesc);

       Levelinfo topLevel = orderinfo.addNewLevel();

       topLevel.setLevelindex("1");

       topLevel.setSamepanelwidth(CurtainDesign.m_UserMainGUI.GetOrderInfo().getSamePanelWidth());

       topLevel.setBoard(CurtainDesign.m_UserMainGUI.GetOrderInfo().getIsBoard());

       topLevel.setHingeinstalltype(CurtainDesign.m_UserMainGUI.GetOrderInfo().GetHingeInstallType());

       topLevel.setPanelnum(CurtainDesign.m_UserMainGUI.GetOrderInfo().GetPanelNum());

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetTPolePos();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         topLevel.setVerticaltposition(tmpstring);
       }

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBendHinge();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         topLevel.setBendhinge(tmpstring);
       }

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetSingleHinge();
       if (!CurtainChecker.isEmpty(tmpstring))
       {
         topLevel.setSinglehinge(tmpstring);
       }

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetDoubleHinge();
       topLevel.setDoublehinge(tmpstring);

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetPoleNum();
       topLevel.setPolenum(tmpstring);

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetDuiKouPoleNum();
       topLevel.setDuikoupolenum(tmpstring);

       topLevel.setShuanglianpolenum(CurtainDesign.m_UserMainGUI.GetOrderInfo().getShuangLianPoleNum());

       tmpint = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetVaneType();
       if (tmpint > -1)
         topLevel.setVanetype(Constants.VANETYPE[tmpint]);
       else {
         topLevel.setVanetype("");
       }

       tmpint = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetDividerType();
       if (tmpint > -1)
         topLevel.setDividertype(Constants.DIVIDERTYPE[tmpint]);
       else {
         topLevel.setDividertype("");
       }

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetDividerNum();

       topLevel.setDividernum(tmpstring);

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetDivederPos();
       topLevel.setDividerpos(tmpstring);

       tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetGap();
       topLevel.setGap(tmpstring);

       if (levelDesc.getLevelnum().trim().equalsIgnoreCase("2"))
       {
         Levelinfo bottomLevel = orderinfo.addNewLevel();

         bottomLevel.setLevelindex("2");

         bottomLevel.setSamepanelwidth(CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomSameWidth());

         bottomLevel.setBoard(CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomIsBoard());

         bottomLevel.setHingeinstalltype(CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomHingeInstallType());

         bottomLevel.setPanelnum(CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomPanelNum());

         bottomLevel.setVerticaltposition(CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomTPolePos());

         bottomLevel.setBendhinge(CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomBendHinge());

         tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomSingeHinge();
         bottomLevel.setSinglehinge(tmpstring);

         tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomDoubleHinge();
         bottomLevel.setDoublehinge(tmpstring);

         tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomPoleNum();
         bottomLevel.setPolenum(tmpstring);

         tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomDuiKouPoleNum();
         bottomLevel.setDuikoupolenum(tmpstring);

         tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomTPolePos();

         bottomLevel.setShuanglianpolenum(CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomShuangLianPoleNum());

         tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomVaneType();
         bottomLevel.setVanetype(tmpstring);

         tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomDividerType();
         bottomLevel.setDividertype(tmpstring);

         tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomDividerNum();
         bottomLevel.setDividernum(tmpstring);

         tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomDividerPos();
         bottomLevel.setDividerpos(tmpstring);

         tmpstring = CurtainDesign.m_UserMainGUI.GetOrderInfo().getBottomGap();
         bottomLevel.setGap(tmpstring);
         orderinfo.setLevelArray(new Levelinfo[] { topLevel, bottomLevel });
       }
       else
       {
         orderinfo.setLevelArray(new Levelinfo[] { topLevel });
       }
       String strComments = CurtainDesign.m_UserMainGUI.GetOrderInfo().GetComments();
       if (!CurtainChecker.isEmpty(strComments))
       {
         String[] commentArray = strComments.split("@@");
         Comments comments = orderinfo.addNewComments();
         comments.setCommentArray(commentArray);
         orderinfo.setComments(comments);
       }
       Translator.chinese2English(orderinfo);
       doc.save(xmlfile);
     }
     catch (Exception e)
     {
       e.printStackTrace();
     }
   }
 }

/* Location:           C:\Users\Administrator\Desktop\奥特百叶窗\Shutter DesignerV3.1\CurtainDesign.jar
 * Qualified Name:     CurtainDesign.OrderFileRectSimple
 * JD-Core Version:    0.6.0
 */